import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/wrapper",
    component: () =>
    import(/* webpackChunkName: "about" */ "./components/Wrapper"),
    children: [{
    path: "/login",
    name: "鹿城区小区改造",
    component: () =>
      import(/* webpackChunkName: "about" */ "./views/Login.vue"),
  },
  {
	path: "/successfulcases/",
	name: "成功案例",
	component: () =>
	  import(/* webpackChunkName: "fans" */ "./views/home/successfulCases.vue"),
  },
  {
  	path: "/advicesuggest/",
  	name: "咨询建议",
  	component: () =>
  	  import(/* webpackChunkName: "fans" */ "./views/home/adviceSuggest.vue"),
  },{
  	path: "/feedback",
  	name: "建议反馈",
  	component: () =>
  	  import(/* webpackChunkName: "fans" */ "./views/home/feedback.vue"),
  },{
      path: "/home",
      name: "首页",
      component: () =>
        import(/* webpackChunkName: "manage" */ "./views/home/home.vue"),
      meta: { isShowTabbar: true }
   },
   {
       path: "/info",
       name: "信息公开",
       component: () =>
         import(/* webpackChunkName: "manage" */ "./views/home/info.vue"),
       meta: { isShowTabbar: true }
    },
	{
	    path: "/infoDetail",
	    name: "详情",
      meta: { num: 1 },
	    component: () =>
	      import(/* webpackChunkName: "manage" */ "./views/home/infoDetail.vue"),
	 },
   {
    path: "/policyPagep",
    name: "政策解读",
    component: () =>
    import(/* webpackChunkName: "manage" */ "./views/home/policyPagep.vue"),
    },
    {
       path: "/approval",
       name: "申请流程",
       component: () =>
       import(/* webpackChunkName: "manage" */ "./views/home/approval.vue"),
    }
    ],
  },
];

const router = new VueRouter({
  routes
})
// 路由守卫
router.beforeEach((to,from,next)=>{
  // if(!to.meta.isShowTabbar) {
  //   document.title = to.name;
  // }
  document.title = to.name;
  next();
  // if(to.matched.some(res=>res.meta.isLogin)){//判断是否需要登录
  //     if (sessionStorage['username']) {
  //         next();
  //     }else{
  //         next({
  //             path:"/login",
  //             query:{
  //                 redirect:to.fullPath
  //             }
  //         });
  //     }

  // }else{
  //     next()
  // }
});
export default router
